import { MUSIC_SRC,MUSIC_CURRENT_DETAIL,MUSIC_CONTROLS,MUSIC_NODE,PLAY_ORDER,MUSIC_LIST,MUSIC_CURRENT_TIME} from '../../constant/type'
//music src和id
const srcInitState = ''
export const musicSrc = (preState=srcInitState,action) => {
    const {type,data}=action
    switch(type){
        case MUSIC_SRC:
            return data
        default:
            return preState
    }
}

//当前播放歌曲的信息
const currentDetailInitState = {}
export const musicCurrentDetail = (preState=currentDetailInitState,action) => {
    const {type,data}=action
    switch(type){
        case MUSIC_CURRENT_DETAIL:
            return data
        default:
            return preState
    }
}

//播放开关
// 初始化是false 播放 true 暂停
const controlsInitState = false
export const musicControls = (preState=controlsInitState,action) => {
    const {type,data}=action
    switch(type){
        case MUSIC_CONTROLS:
            return data
        default:
            return preState
    }
}

//ref--Audio
const nodeInitState = null
export const musicNode = (preState=nodeInitState,action) => {
    const {type,data}=action
    switch(type){
        case MUSIC_NODE:
            return data
        default:
            return preState
    }
}

//0是循环播放 1是顺序播放
const playOrderInitState = 1
export const playOrder = (preState=playOrderInitState,action) => {
    const {type,data}=action
    switch(type){
        case PLAY_ORDER:
            return data
        default:
            return preState
    }
}

//当前在播放的歌单
const listInitState = []
export const musicList = (preState=listInitState,action)=>{
    const {type,data}=action
    switch(type){
        case MUSIC_LIST:
            return data
        default:
            return preState
    }
}
//当前播放歌词的时间
const currentTimeInitState = {}
export const musicCurrentTime = (preState=currentTimeInitState,action)=>{
    const {type,data}=action
    switch(type){
        case MUSIC_CURRENT_TIME:
            return data
        default:
            return preState
    }
}


